//
//  JZMTBtnView.m
//  meituan
//  自定义美团菜单view
//  Created by jinzelu on 15/6/30.
//  Copyright (c) 2015年 jinzelu. All rights reserved.
//

#import "JZMTBtnView.h"

@implementation JZMTBtnView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        CGFloat widthB = CGRectGetWidth(frame);        
        self.imageView = [[UIImageView alloc]init];
        [self addSubview:self.imageView];
        [self.imageView makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.top).with.offset(5);
            make.centerX.equalTo(self.centerX).with.offset(0);
            make.width.mas_equalTo(@(widthB));
            make.height.mas_equalTo(@(widthB));
            
//            make.width.mas_equalTo(@(50));
//            make.height.mas_equalTo(@(50));
        }];
        
        self.titleLable= [[UILabel alloc] init];
        self.titleLable.textAlignment = NSTextAlignmentCenter;
        self.titleLable.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.titleLable];
        [self.titleLable makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.imageView.bottom).with.offset(3);
            make.centerX.equalTo(self.centerX).with.offset(0);
            make.width.mas_equalTo(@(frame.size.width+20));
            make.height.mas_equalTo(@(21));
        }];
    }
    return self;
}
-(void)setTitleColor:(UIColor *)titleColor{
    _titleColor = titleColor;
    self.titleLable.textColor = titleColor;
}

-(void)setImageStr:(NSString *)imageStr{
    _imageStr = imageStr;
    [_imageView setImage:[UIImage imageNamed:imageStr]];
    [self setNeedsDisplay];
}

-(void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    _titleLable.text =[NSString stringWithFormat:@"%@",titleStr];
    [self setNeedsDisplay];
}

-(void)setFont:(UIFont *)font{
    _font = font;
    _titleLable.font = font;
}

@end
